package com.xiaoma.thread;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author xiaomacdut
 * @date 2020年2月13日 下午12:43:38
 */
public class Demo implements Runnable{
    
    private static AtomicInteger integer = new AtomicInteger();
    @Override
    public void run(){
        integer.incrementAndGet();
        
    }
    
    public static void test3() throws InterruptedException{
        for(int j = 0; j < 100; j++){
            new Thread(){
                @Override
                public void run(){
                    integer.addAndGet(1);
                }
                
            }.start();
            
            
        }
        
        Thread.sleep(1000);
        // System.out.println(integer.get());
    }
    
    public static void main(String [] args) throws InterruptedException{

        /*        Demo demo = new Demo();
        for(int i = 1; i < 100; i++){
            new Thread(demo).start();
        }*/
        test3();
    }
    
}
